package com.study.talk.adapter;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.viewpager2.adapter.FragmentStateAdapter;

import java.util.List;

public class ViewPager2StateAdapter extends FragmentStateAdapter{
        List<Fragment> fragmentList;

        public ViewPager2StateAdapter(Fragment fragment,List<Fragment> fragmentList){
            super(fragment);
            this.fragmentList = fragmentList;
        }

        public ViewPager2StateAdapter(FragmentActivity fragmentActivity, List<Fragment> fragmentList){
            super(fragmentActivity);
            this.fragmentList = fragmentList;
        }

        @NonNull
        @Override
        public Fragment createFragment(int position) {
            return fragmentList.get(position);
        }

        @Override
        public int getItemCount() {
            return fragmentList.size();
        }
}
